<?
#error_reporting(0);
include("../config/header.php");
?>
<script type='text/javascript'>
	document.title = '在线脚本语法高亮 —— 在线工具';
</script>
<link href="<?php echo $url;?>content/css/shCoreDefault.css" rel="stylesheet" type="text/css" />
<script src="<?php echo $url;?>content/js/jquery.min.js"></script>
<script src="<?php echo $url;?>content/js/shCore.js" type="text/javascript"></script>
<script src="<?php echo $url;?>content/js/shAutoloader.js" type="text/javascript"></script>
<div class="container" id="input">
	<div class="panel panel-primary">
		<div class="panel-heading"><h3 class="panel-title">在线脚本语法高亮</h3></div>
	</div>
	<div class="form-group" id="options" style="display:none">
		<label>行数：</label><input type="checkbox" id="gt" checked>高亮线：<input type="input" id="hl" size="10">（例如，[ 6 ]）
	</div>
	<div class="form-group">
		<textarea id="textarea" name="textarea" onkeyup="" class="form-control" style="width:100%;height:250px;border:1px solid #c5e2f2;overflow:visible;" placeholder="">console.log("Who's your daddy?");
// v1.0 2014-09-30 19:40 工具上线</textarea>
	</div>
	<div class="form-group">
        <label>编写语言:</label>
        <select id="syntax"></select>
        <input type="button" id="highlight" class="button button-rounded button-flat-primary" value="着色[highlight]!">
	</div>
	<div class="form-group">
		<div id="output" style="display:none"></div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$("#highlight").click(function(){
		$("div#output").show().empty().append("<pre>"+$("#textarea").val()+"</pre>");
		var klass = "brush: "+$("#syntax option:selected").text();
		if (!$("div#options #gt").attr("checked")) klass += "; gutter: false";
		if ($.trim($("div#options #hl").val()) != "") klass += "; highlight: "+$("div#options #hl").val();
		$("div#output pre").addClass(klass);
		highlightall();
		$("div#input").data("smarthide")();
	})
	
	$("div#input").data("smarthide", function (){
		$("div#input #options h2, div#input #code h2").hide();
		$("div#input #textarea").show().attr("rows", "2").bind("click", $("div#input").data("smartshow"));
	});
	
	$("#input").data("smartshow", function (){
		$("div#input *").show();
		$("div#input #textarea").attr("rows", "15").unbind("click", $("div#input").data("smartshow"));
	});
	
	var brushes = [
		'applescript            @shBrushAppleScript.js',
		'as3                    @shBrushAS3.js',
		'shell                  @shBrushBash.js',
		'coldfusion             @shBrushColdFusion.js',
		'cpp                    @shBrushCpp.js',
		'c#                     @shBrushCSharp.js',
		'css                    @shBrushCss.js',
		'delphi                 @shBrushDelphi.js',
		'diff                   @shBrushDiff.js',
		'erlang                 @shBrushErlang.js',
		'groovy                 @shBrushGroovy.js',
		'html                   @shBrushXml.js',
		'java                   @shBrushJava.js',
		'javafx                 @shBrushJavaFX.js',
		'javascript             @shBrushJScript.js',
		'perl                   @shBrushPerl.js',
		'php                    @shBrushPhp.js',
		'plain                  @shBrushPlain.js',
		'python                 @shBrushPython.js',
		'ruby                   @shBrushRuby.js',
		'sass                   @shBrushSass.js',
		'scala                  @shBrushScala.js',
		'sql                    @shBrushSql.js',
		'vb                     @shBrushVb.js',
		'xml                    @shBrushXml.js'
	];
	
	for (var i=0; i<brushes.length; ++i) {
		var syn = brushes[i].split(/\s+/)[0]
		$("#syntax").append("<option>"+syn+"</option>");
	}
	
	var highlightall = (function(){
		var result = [];
		for(var i = 0; i < brushes.length; i++)
			result.push(brushes[i].replace('@', "http://alexgorbatchev.com/pub/sh/current/scripts/"));
		return function () {
			SyntaxHighlighter.vars.discoveredBrushes = null;
			SyntaxHighlighter.autoloader.apply(SyntaxHighlighter, result);
			SyntaxHighlighter.all();
		};
	})()
})
</script>
<?php
include("../config/footer.php");
?>
